import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from sqqueue import CsqQueue

def push_k(queue, k, e):
    n = queue.size()
    if k < 1 or k > n+1:
        return False
    if k >= 1 and k < n+1:
        for _ in range(k-1):
            x = queue.pop()
            queue.push(x)
        queue.push(e)
        for _ in range(n-k+1):
            x = queue.pop()
            queue.push(x)
    if k == n+1:
        queue.push(e)
        
def pop_k(queue, k):
    n = queue.size()
    if k < 1 or k > n:
        return False
    if k >= 1 or k <= n:
        for _ in range(k-1):
            x = queue.pop()
            queue.push(x)
        queue.pop()
        for _ in range(n-k):
            x = queue.pop()
            queue.push(x)

if __name__ == "__main__":
    queue = CsqQueue()
    for i in range(10):
        queue.push(i)
    push_k(queue, k=11, e=10)
    # while not queue.empty():
    #     print(queue.pop())
    pop_k(queue, k=2)
    while not queue.empty():
        print(queue.pop())